package com.easypay.reactive8583;

import com.solab.iso8583.IsoMessage;
import io.netty.channel.ChannelHandlerContext;

/**
 * @author pandans
 * @date 2021/03/04 14:50
 * @Description:
 */
public interface IsoMessageListener<T extends IsoMessage> {
    /**
     * Returns `true` if given message can be handled
     * by [.onMessage].
     *
     * @param isoMessage ISO message to check. Not null.
     * @return true if message should be handled.
     */
    boolean applies(T isoMessage);

    /**
     * Handles the message. If message should not be processed by any other handlers
     * then this method should return `false`.
     *
     * @param ctx        current [ChannelHandlerContext]
     * @param isoMessage received isoMessage. Not null.
     * @return true if message should be handled by subsequent message listeners
     */
    boolean onMessage(ChannelHandlerContext ctx, T isoMessage);
}
